package cn.skyquant.quant4j.jforex.sdk.strategy;

import java.util.Objects;

public abstract class BaseConfig {
    public final int index;//序列
    public final double m;//仓位倍率
    public final double lossLimit;//最大损失控制
    public final String name;

    public BaseConfig(String name,int index, double m, double lossLimit) {
        this.index = index;
        this.m = m;
        this.lossLimit = lossLimit * m;
        this.name = name;
    }

    public abstract boolean isValid();

    @Override
    public String toString() {
        return name+"_"+index;
    }

    public String getKey(){
        return name+"_"+index;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        BaseConfig that = (BaseConfig) o;
        return index == that.index &&
                Objects.equals(name, that.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(index, name);
    }
}
